<template>
  <div class="products-page">
    <div class="side-nav">
      <div class="nav-title">
        <span class="dot"></span>
        <span class="nav-title-text">产品项目</span>
      </div>
      <ul class="nav-list">
        <li v-for="item in navItems" :key="item.path">
          <router-link
            :to="`/products/${item.path}`"
            class="nav-link"
            active-class="active"
          >
            {{ item.label }}
          </router-link>
        </li>
      </ul>
    </div>
    <div class="products-content">
      <!-- 面包屑导航 -->
      <nav class="breadcrumb">
        <router-link to="/">首页</router-link>
        <span class="breadcrumb-sep">/</span>
        <router-link to="/products">产品项目</router-link>
        <template v-if="currentNav">
          <span class="breadcrumb-sep">/</span>
          <router-link :to="`/products/${currentNav.path}`">{{ currentNav.label }}</router-link>
        </template>
      </nav>
      <router-view />
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'

const navItems = [
  { label: '饰品', path: 'jewelry' },
  { label: '护肤', path: 'skin' },
  { label: '面膜', path: 'mask' },
  { label: '彩妆', path: 'makeup' },
  { label: '香水', path: 'perfume' },
  { label: '美甲', path: 'nail' },
  { label: '纹绣', path: 'tattoo' },
  { label: '内衣', path: 'underwear' },
  { label: '养生', path: 'health' }
]

const route = useRoute()
const currentNav = computed(() => {
  // 匹配二级路由
  const match = navItems.find(item => route.path.endsWith(item.path))
  return match
})
</script>

<style lang="scss" scoped>
.products-page {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  background: #fafafa;
  min-height: 600px;
}

.side-nav {
  width: 220px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 30px 0 0 0;
  margin-right: 40px;
}

.nav-title {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  padding-left: 30px;
  .dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #333;
    margin-right: 8px;
    position: relative;
    &::after {
      content: '';
      display: block;
      width: 8px;
      height: 8px;
      background: #333;
      border-radius: 50%;
      position: absolute;
      left: 3px;
      top: 3px;
    }
  }
  .nav-title-text {
    font-size: 22px;
    color: #333;
    font-weight: bold;
  }
}

.nav-list {
  list-style: none;
  padding: 0 30px;
  margin: 0;
  .nav-link {
    display: block;
    text-align: center;
    font-size: 18px;
    color: #333;
    padding: 18px 0;
    border-bottom: 1px dashed #ccc;
    text-decoration: none;
    transition: color 0.2s;
    &:hover,
    &.active {
      color: #ff6b9d;
      font-weight: bold;
    }
    &:last-child {
      border-bottom: none;
    }
  }
}

.products-content {
  flex: 1;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 30px;
  min-height: 400px;
}

.breadcrumb {
  margin-bottom: 24px;
  font-size: 15px;
  color: #888;
  display: flex;
  align-items: center;
  a {
    color: #888;
    text-decoration: none;
    &:hover {
      color: #ff6b9d;
      text-decoration: underline;
    }
  }
  .breadcrumb-sep {
    margin: 0 8px;
    color: #bbb;
  }
}
</style>